<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label">下拉项名称</label>
            <div class="layui-input-block">                     
                <input name="name"  required value='{$info.name|default=""}' placeholder="请输入下拉项名称" class="layui-input">                                          
            </div>
        </div>
		
		<div class="layui-form-item">
            <label class="layui-form-label">下拉项排序</label>
            <div class="layui-input-block">
                <input name="sort" required value='{$info.sort|default="0"}' type="number"  lay-ignore placeholder="请输入下拉项排序（数字越大越靠前）" class="layui-input">
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">下拉项描述</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea"  name="desc" >{$info.desc|default=''}</textarea>
            </div>
        </div>


    </div>

    <div class="hr-line-dashed"></div>
    <input type='hidden' value='{$dropdown_id}' name='dropdown_id'>
    {notempty name='info.id'}<input type='hidden' value='{$info.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存</button>
        <button class="layui-btn layui-btn-danger" type='button'  data-close>取消</button>
    </div>
    <script>window.form.render();</script>
</form>
<script>

    form.on('select(typeId)', function(data){

        console.log(data.value); //得到被选中的值
        if(data.value){
            $.form.load('{:url("getService")}', {typeId : data.value}, "post", function (ret) {

                $(".serviceId").html('<option value="">请选择服务</option>')
                if (ret.code === 1) {
                    var data = ret.data;
                    for(i in data){
                        $(".serviceId").append('<option value="'+data[i].id+'">'+data[i].title+'</option>')
                    }

                } else {
                    $.msg.auto(ret.info, 1)

                }
                form.render()
                return false;
            })
        }else{
            $(".serviceId").html('<option value="">请选择服务</option>')
        }

        form.render();

    });
    form.render();
</script>
<style>
     .layui-form-selected dl{
        max-height: 158px;
    }
    .layui-card-body{
        height: 180px;
    }
</style>